<?php


namespace App\Models;


class ImThirdPartyConfigs extends BaseModel
{
    //第三方配置表
    protected $table = 'im_third_party_configs';

    //操作者
    public function operator()
    {
        return $this->belongsTo(ImAccount::class, 'operator', 'id')
            ->select(['username', 'id', 'phone']);
    }

    //更改字段值
    public function getValueAttribute($value)
    {
        if (isset($value)) {
            $value = json_decode($value, true);
            if (!empty($value) && is_array($value)) {
                foreach ($value as $key) {
                    if ($key === 'selfTitle') {
                        unset($value[$key]);
                    }
                }
            }
        }
        return $value;
    }
}
